<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>文件下载服务器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        .file-list {
            list-style: none;
            padding: 0;
        }
        .file-item {
            padding: 10px;
            border-bottom: 1px solid #eee;
        }
        .file-item a {
            text-decoration: none;
            color: #2196F3;
        }
        .upload-section {
            margin: 20px 0;
            padding: 20px;
            background-color: #f5f5f5;
            border-radius: 4px;
        }
        .upload-button {
            background-color: #2196F3;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        .message {
            padding: 10px;
            margin: 10px 0;
            border-radius: 4px;
        }
        .success { background-color: #dff0d8; }
        .error { background-color: #f2dede; }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>文件下载服务器</h1>
        <div th:if="${session.isLoggedIn}">
            <a href="/logout" style="color: #666;">退出登录</a>
        </div>
    </div>

    <div class="upload-section" th:if="${session.isLoggedIn}">
        <form method="POST" action="/upload" enctype="multipart/form-data">
            <input type="file" name="file" required>
            <button type="submit" class="upload-button">上传文件</button>
        </form>
    </div>
    <div class="upload-section" th:unless="${session.isLoggedIn}">
        <p>请<a href="/login">登录</a>后进行文件上传</p>
    </div>

    <div th:if="${param.success}" class="message success">
        文件上传成功！
    </div>
    <div th:if="${param.error}" class="message error">
        文件上传失败！
    </div>

    <h2>文件列表</h2>
    <ul class="file-list">
        <li class="file-item" th:each="file : ${files}">
            <a th:href="@{'/files/' + ${file}}" th:text="${file}"></a>
        </li>
    </ul>
</body>
</html> 